<template>
  <div class="templates-view">
    <div class="leftSidebar-container">
      <left-sidebar
        :datas="menu"
        @update-view="updateView"
      ></left-sidebar>
    </div>
    <div class="centerView-container">
      <router-view v-if="isRouterAlive"/>
    </div>
  </div>
</template>

<script>

  export default {
    data() {
      return {
        menu:[],
        isRouterAlive: true
      };
    },
    created() {
        let index = this.$store.getters.userInfo.menus.findIndex(a=>a.code === "store")
        if(index !== -1){
            this.menu =  this.$store.getters.userInfo.menus[index].children
        }
      this.menu.forEach(item=>{
        item.iconType = "iconFont"
        item.iconFont = item.icon
      })
    },
    mounted(){

    },
    methods: {
      reload() {
        this.isRouterAlive = false;
        this.$nextTick(function () {
          this.isRouterAlive = true
        })
      },
      updateView: function () {
        this.reload()
        // if (this.$refs["routerView"].updateApi) {
        //   this.$refs["routerView"].updateApi();
        // }
      },
    }
  }

</script>
<style lang="scss" scoped>
  @import "@/assets/scss/drugsManagement/index.scss";
</style>
